<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript">
        function Grand() {}  //爷爷
        function Parent() {} //爸爸
        Grand.prototype.tskill = '拉二胡';
        var grand = new Grand();
        // Parent.prototype = grand;
        var parent = new Parent();
        Parent.prototype.tskill = '弹琴';        
        console.log(parent.tskill);
        console.log(grand.tskill);
//  1. 
    function Test(name,age){
    this.name = name;
    this.age = age;
   }
   obj = {}
// 分别使用call，apply为obj添加name，age属性
   Test.call(obj,'张三',18)
   Test.apply(obj,['张三',18])
   console.log(obj);
// 2.
// 实现陈鹏买车，其中有sayHi方法，功能:打印'陈鹏买了一辆红色的2.0宝马车'
   function sayHi(name,car,corlor) {
        this.name = name
        this.car =car
        this.corlor=corlor
   }
   var sayhi = new sayHi('陈鹏','宝马','红色')
   console.log(sayhi.name+'买了一辆'+sayhi.corlor+'的2.0'+sayhi.car+'车');
// 3.父类Shape （属性有:name,length,width,方法有:Intro 我是XX形）

// 子类： Circle(属性有:r)

// 分别使用 原型链继承 构造函数继承 圣杯继承
    //原型链继承
    // function Shape(name,length,width) {
    //     this.name=name
    //     this.length=length
    //     this.width=width
    // }
    // function circle(x) {
    //     this.x=x
    // }
    // Shape.prototype.Intro = () =>{console.log(我是XX形);}
    // var shape =new Shape('正方形',8,8)
    // circle.prototype=shape
    // var circle=new circle(9)
    // console.log(circle);
    //构造函数继承
    // function Shape(name,length,width) {
    //     this.name=name
    //     this.age=length
    //     this.width=width
    // }
    // Shape.prototype.Intro = () =>{console.log(我是XX形);}
    // function circle(x,name,length,width) {
    //     Shape.call(this,name,length,width)
    //     this.x=x
    // }
    // var cir = new circle('9','正方形',8,8)
    // console.log(cir);
    //圣杯继承
    // function Shape() {
    // }
    // function circle() {
    // }
    // Shape.prototype.Intro = () =>{console.log(我是XX形);}
    // Shape.prototype.name='正方形'
    // Shape.prototype.length='8'
    // Shape.prototype.width='8'
    // function inherit(Target, Origin) {
    //     function change() {
    //     }
    //     change.prototype=Origin.prototype
    //     Target.prototype=new change()
        
    // }
    // inherit(circle,Shape)
    // var cir = new circle()
    // circle.prototype.r=9
    // console.log(cir);
    </script>
</head>
<body>
    
</body>
</html>